home *** CD-ROM | disk | FTP | other *** search
/ Programming Microsoft Visual Basic .NET / Programming Microsoft Visual Basic .NET (Microsoft Press)(X08-78517)(2002).bin / setup / vbnet / 23 web forms and controls / firstwebforms / validationform.aspx < prev    next >
Encoding:
ASP.NET Web Form  |  2002-03-17  |  4.0 KB  |  38 lines

  1. <%@ Page Language="vb" AutoEventWireup="false" Codebehind="ValidationForm.aspx.vb" Inherits="FirstWebForms.ValidationForm" %>
  2. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  3. <HTML>
  4.     <HEAD>
  5.         <title>ValidationForm</title>
  6.         <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
  7.         <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
  8.         <meta content="JavaScript" name="vs_defaultClientScript">
  9.         <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
  10.     </HEAD>
  11.     <body>
  12.         <form id="Form1" method="post" runat="server">
  13.             <H1>Validation Controls Demo</H1>
  14.             <P>This page demonstrates the features of all the 5 validation controls and the 
  15.                 ValidationSummary control.</P>
  16.             <P><asp:validationsummary id="ValidationSummary1" runat="server" Height="83px" HeaderText="Please correct the following errors" EnableViewState="False" ShowMessageBox="True" Width="501px"></asp:validationsummary></P>
  17.             <P><asp:label id="Label1" runat="server">Name (required)</asp:label><asp:textbox id="txtUserName" runat="server" Width="135px"></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" ControlToValidate="txtUserName">The name is required !</asp:requiredfieldvalidator></P>
  18.             <P><asp:label id="Label2" runat="server">Year Born (1901-2000)</asp:label><asp:textbox id="txtYearBorn" runat="server" Width="88px"></asp:textbox><asp:rangevalidator id="RangeValidator1" runat="server" ControlToValidate="txtYearBorn" Type="Integer" MaximumValue="2000" MinimumValue="1901" ErrorMessage="The Year Born field must be in the range [1901-2000]">*</asp:rangevalidator>  <asp:label id="Label3" runat="server">Year married (> year born)</asp:label><asp:textbox id="txtYearMarried" runat="server" Width="69px"></asp:textbox><asp:comparevalidator id="CompareValidator1" runat="server" ControlToValidate="txtYearMarried" ErrorMessage="The Year Married field must be later than the Year Born field" Operator="GreaterThan" ControlToCompare="txtYearBorn">*</asp:comparevalidator></P>
  19.             <P><asp:label id="Label7" runat="server">Date of last visit</asp:label><asp:textbox id="txtLastVisit" runat="server" Width="143px"></asp:textbox><asp:comparevalidator id="CompareValidator2" runat="server" ControlToValidate="txtLastVisit" Type="Date" ErrorMessage="Date of last visit isn't valid" Operator="DataTypeCheck">*</asp:comparevalidator>  <asp:label id="Label8" runat="server">Number of Children (>= 0)</asp:label><asp:textbox id="txtChildren" runat="server" Width="94px"></asp:textbox><asp:comparevalidator id="CompareValidator3" runat="server" ControlToValidate="txtChildren" Type="Integer" ErrorMessage="Number of Children must be an integer >= zero" Operator="GreaterThan" ValueToCompare="0">*</asp:comparevalidator></P>
  20.             <P><asp:label id="Label4" runat="server">Phone number </asp:label><asp:textbox id="txtPhoneNumber" runat="server"></asp:textbox><asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" ControlToValidate="txtPhoneNumber" ErrorMessage="The Phone Number must be in (###)###-#### format">*</asp:regularexpressionvalidator></P>
  21.             <P><asp:label id="Label5" runat="server">An even number</asp:label><asp:textbox id="txtEvenNumber" runat="server" Width="143px"></asp:textbox><asp:customvalidator id="CustomValidator1" runat="server" ControlToValidate="txtEvenNumber" ErrorMessage="Enter an even value" ClientValidationFunction="CheckEvenNumber">*</asp:customvalidator>  
  22.                 <asp:literal id="Literal1" runat="server"></asp:literal></P>
  23.             <P><asp:button id="Button1" runat="server" Text="Submit"></asp:button></P>
  24.             <P><asp:label id="lblStatus" runat="server" Font-Bold="True" ForeColor="Magenta"></asp:label></P>
  25.             <script language="JScript"><!--
  26.         function CheckEvenNumber(o, args) {
  27.             var theNumber = args.Value;
  28.             if (theNumber % 2 == 0) 
  29.                 args.IsValid = true;
  30.             else
  31.                 args.IsValid = false;
  32.         }
  33.         //-->
  34.             </script>
  35.         </form>
  36.     </body>
  37. </HTML>
  38.